package leetcode.median;

public class $299_GetHint {
    public String getHint(String secret, String guess) {
        int countA = 0;
        int countB = 0;
        int[] s = new int[10];
        int[] g = new int[10];
        for (int i = 0;i < secret.length();i++) {
            if (secret.charAt(i) == guess.charAt(i)) {
                countA++;
            } else {
                s[secret.charAt(i) - '0']++;
                g[guess.charAt(i) - '0']++;
            }
        }
        for (int i = 0;i < 10;i++) {
            countB += Math.min(s[i], g[i]);
        }
        StringBuilder sb = new StringBuilder();
        return sb.append(countA).append('A').append(countB).append('B').toString();
    }
}
